package br.fmapn.web.mb;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.faces.context.FacesContext;
import javax.jms.Session;

import org.richfaces.component.html.HtmlDataTable;

import br.fmapn.process.entities.BusinessOperation;
import br.fmapn.process.entities.BusinessProcess;
import br.fmapn.register.BusinessProcessServicesRemote;
import br.fmapn.reporter.BusinessProcessReporterRemote;
import br.fmapn.web.util.GerenciadorLookup;

public class MBManterReporter {

	BusinessProcessReporterRemote businessProcessReporter;
	BusinessProcessServicesRemote businessProcessServices;
	
	private BusinessProcess businessProcess;
	private List<BusinessOperation> listaOperacoes;
	
	public MBManterReporter() {
		businessProcessReporter = GerenciadorLookup.obterBusinessProcessReporter();
		//businessProcessServices = GerenciadorLookup.obterBusinessProcessServices();
		setBusinessProcess(new BusinessProcess());
		setListaOperacoes(new ArrayList<BusinessOperation>());
	}
	
	public String redirecionarDetalhes() throws IOException{
		HtmlDataTable dataTable = (HtmlDataTable)FacesContext.getCurrentInstance().getViewRoot().findComponent("form:listaProcessosCadastrados");  
		setBusinessProcess((BusinessProcess) dataTable.getRowData());
		FacesContext.getCurrentInstance().getExternalContext().redirect("/FMAPN/jsp/TelaDetalhesProcesso.jsf");
		return "";
	}
	

	public void setBusinessProcess(BusinessProcess businessProcess) {
		this.businessProcess = businessProcess;
	}

	public BusinessProcess getBusinessProcess() {
		return businessProcess;
	}

	public void setListaOperacoes(List<BusinessOperation> listaOperacoes) {
		this.listaOperacoes = listaOperacoes;
	}

	public List<BusinessOperation> getListaOperacoes() {
		listaOperacoes = businessProcessReporter.getOperationsMappingEfficienceByBusinesProcess(businessProcess);
		return listaOperacoes;
	}
}
